var mongoose = require('mongoose')
mongoose.connect('mongodb://127.0.0.1/blog',{ useNewUrlParser: true })
var schema = mongoose.Schema
var commentsSchema = new schema({
    //作者
    author:{
        type:Object,
    },
    title:{
        type:String,
    },
    message:{
        type:String,
    },
    createTime:{
        type:Date,
        default:Date.now
    },
    lastModifiedTime:{
        type:Date,
        default:''
    },
    //点赞量
    like:{
        type:Array,
        //[userid]
        default:[]
    },
    //回复
    replys:{
        type:Array,
        //[{userid,message}]
        default:[]
    },
    //浏览量
    read:{
        type:Array,
        //[userid]
        default:[]
    },
    //评论状态
    //0 正常
    //1 被屏蔽
    status:{
        type:Number,
        enum:[0,1],
        default:0
    },
})
module.exports = mongoose.model('Comment',commentsSchema)